package com.asia5b.a5mall.order.adapter

import androidx.core.content.ContextCompat
import android.widget.TextView
import com.asia5b.a5mall.middleware.model.bean.OrderPlacePriceMenuBean

import com.asia5b.a5mall.middleware.utils.CurrencyPriceBuilder3
import com.asia5b.a5mall.order.R
import com.asia5b.a5mall.order.databinding.ItemOrderplacePriceBinding
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * Created by zhangyuncai on 2020/1/9.
 */
class OrderPlacePriceAdapter(list: ArrayList<OrderPlacePriceMenuBean>) :
        BaseQuickAdapter<OrderPlacePriceMenuBean, BaseDataBindingHolder<ItemOrderplacePriceBinding>>(R.layout.item_orderplace_price, list) {
    override fun convert(helper: BaseDataBindingHolder<ItemOrderplacePriceBinding>, item: OrderPlacePriceMenuBean) {
        //名称
        val tv_orderplace_price_name = helper.getView<TextView>(R.id.tv_orderplace_price_name)
        tv_orderplace_price_name.text = item.name
        //值
        val tv_orderplace_price_value = helper.getView<TextView>(R.id.tv_orderplace_price_value)
//        tv_orderplace_price_value.text = item.value
        CurrencyPriceBuilder3().run {
            textView = tv_orderplace_price_value
            price = item.price
            priceList = item.priceList
            build()
        }
        if (item.priceType == 0) {
            tv_orderplace_price_value.setTextColor(ContextCompat.getColor(context, R.color.common_text_black))
        } else {//价格显示红色
            tv_orderplace_price_value.setTextColor(ContextCompat.getColor(context, R.color.color_red))
            if (item.priceType == 1) {
                tv_orderplace_price_value.text="+${tv_orderplace_price_value.text}"
            }else{
                tv_orderplace_price_value.text="-${tv_orderplace_price_value.text}"
            }
        }
    }
}